<template>
  <div class="login">
    <img src="@/assets/img/login/logo.png" alt="" class="logo" />
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        placeholder="请输入手机号"
        :rules="[{ pattern }]"
        @input="dis()"
      />
      <div style="margin: 0.32rem">
        <van-button
          round
          block
          type="info"
          native-type="submit"
          :disabled="isDis"
          >获取验证码</van-button
        >
      </div>
    </van-form>
    <p class="wenti">登录遇到问题 ></p>
    <div class="xian">
      <p></p>
      <span>其他登陆方式</span>
      <p></p>
    </div>
    <div class="qita">
      <img src="../assets/img/login/微信登录.jpg" alt="" />
      <img src="../assets/img/login/QQ登录.jpg" alt="" />
      <img src="../assets/img/login/苹果登录.jpg" alt="" />
    </div>
    <div class="xieyi">
      <i :class="{ xuan: isXuan }" @click="isXuan = !isXuan"></i>
      <p>
        我已阅读并同意 <span>《用户协议》</span> 和
        <span>《隐私政策》</span> 并授权闪验获取 本机号码
      </p>
    </div>
    <van-notify v-model="show" type="warning">
      <van-icon name="bell" style="margin-right: 0.04rem" />
      <span>请勾选用户协议</span>
    </van-notify>
  </div>
</template>

<script>
import { postSmsLog } from "@/services";
export default {
  data() {
    return {
      username: "",
      pattern: /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/,
      isDis: true,
      isXuan: false,
      show: false,
    };
  },
  methods: {
    showNotify() {
      this.show = true;
      setTimeout(() => {
        this.show = false;
      }, 1000);
    },
    onSubmit(values) {
      // console.log("submit", values);
      if (this.isXuan) {
        postSmsLog(values.username).then((res) => {
          this.$router.push({
            path: "/login2",
            query: { phone: values.username },
          });
        });
      } else {
        this.showNotify();
      }
    },
    dis() {
      this.isDis = !this.pattern.test(this.username);
    },
  },
};
</script>

<style lang="scss">
.login {
  .van-notify {
    font-size: 30px;
    height: 50px;
  }
  .logo {
    width: 236px;
    height: 110px;
    margin-top: 333px;
    margin-left: 257px;
  }
  form {
    height: 240px;
    .van-cell {
      width: 600px;
      margin: 0 auto;
      margin-top: 178px;
      background-color: #ffffff;
      border-radius: 44px;
      font-size: 24px !important ;
      line-height: 70px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #999999;
      .van-field__error-message {
        font-size: 25px;
      }
    }
    .van-button--round {
      width: 600px;
      height: 88px;
      font-size: 30px;
      margin: 0 auto;
      margin-top: 46px;
      background-color: #63d197;
      color: #fff;
    }
  }
  .wenti {
    margin-top: 68px;
    text-align: center;
    color: #999999;
    font-size: 24px;
  }
  .xian {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 303px;
    span {
      width: 190px;
      text-align: center;
      font-size: 22px;
      font-family: PingFang SC;
      font-weight: 400;
      color: #666666;
      padding: 0 20px;
    }
    p {
      width: 180px;
      border-top: 2px solid #ffffff;
      opacity: 0.5;
    }
  }
  .qita {
    padding: 30px 164px;
    display: flex;
    justify-content: space-between;
    img {
      width: 80px;
      height: 80px;
      border-radius: 50%;
    }
  }
  .xieyi {
    display: flex;
    i {
      display: block;
      width: 24px;
      height: 24px;
      border: 1px solid #fff;
      border-radius: 50%;
      margin-left: 36px;
      margin-right: 8px;
      margin-top: 8px;
    }
    .xuan {
      background-image: url(../assets/img/login/Button.jpg);
      background-size: 100% 100%;
      border: none;
    }
    p {
      width: 648px;
      font-size: 24px;
      color: #999999;
      line-height: 40px;
      span {
        color: #5375ea;
      }
    }
  }
}
</style>
